"""
 列表合并
"""
from day01_链式线性表 import *

l1 = LinkList()
l2 = LinkList()

l1.init_list([1, 5, 7, 8, 10, 12, 13, 19])
l2.init_list([2, 3, 4, 9, 16, 17, 20])


def merge(lis1, lis2):
	# 将l2合并到l1中
	p = lis1.head
	q = lis2.head.nxt
	while p.nxt is not None:
		if p.nxt.val < q.val:
			p = p.nxt
		else:
			tmp = p.nxt
			p.nxt = q  # 前面两步提前指定
			p = p.nxt
			q = tmp
	p.nxt = q

merge(l1, l2)
l1.show()
# l2.show()
